using System.Collections.Generic;
using System.Drawing;
using dk.Helper.Base;
using dk.Helper.Base.Core;
using NUnit.Framework;

namespace dk.Helper.Base.Core
{
    public class PlayerGroupVillages : IPlayerGroupVillages
    {
        public PlayerGroupVillages(IPlayer player)
        {
            GroupVillages = new Dictionary<IVillage, IVillageGroups>();
            foreach (IVillage village in player.Villages)
            {
                GroupVillages.Add(village, new VillageGroups(village));
            }
        }

        public IDictionary<IVillage, IVillageGroups> GroupVillages { get; private set; }
    }
}

namespace dk.Helper.Base
{
    public interface IPlayerGroupVillages
    {
        IDictionary<IVillage, IVillageGroups> GroupVillages { get; }
    }
}

namespace dk.Helper.Test
{
    [TestFixture]
    public class PlayerVillageGroupsTest
    {
        private IPlayer player;
        private IPlayerGroupVillages playerGroupVillages;
        private Village village1;
        private Village village2;
        private Village village3;
        
        [SetUp]
        public void SetUp()
        {
            village1 = new Village(1, "Village1", new Point(0, 1), 1, 0, 0);
            village2 = new Village(2, "Village2", new Point(0, 2), 1, 0, 0);
            village3 = new Village(3, "Village3", new Point(0, 3), 1, 0, 0);
            this.player = new Player(1, "Player Test Name", 0, 3, 0, 0,
                                     new List<IVillage> {village1,
                                                         village2,
                                                         village3,
                                     });
            this.playerGroupVillages = new PlayerGroupVillages(player);
        }

        [Test]
        public void GroupVillages_NotNull()
        {
            Assert.IsNotNull(playerGroupVillages.GroupVillages);
        }

        [Test]
        public void GroupVillages_ContainsVillages1()
        {
            Assert.IsTrue(this.playerGroupVillages.GroupVillages.ContainsKey(village1));
        }

        [Test]
        public void GroupVillages_ContainsVillages2()
        {
            Assert.IsTrue(this.playerGroupVillages.GroupVillages.ContainsKey(village2));
        }

        [Test]
        public void GroupVillages_ContainsVillages3()
        {
            Assert.IsTrue(this.playerGroupVillages.GroupVillages.ContainsKey(village3));
        }
    }
}
